package com.silence.FinalTest;

import java.util.*;

public class Q1 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        ArrayList<double[][]> arr_list = new ArrayList<>();
        ArrayList<double[][]> reverse_list = new ArrayList<>();
        for (int i=0;i<a;i++){
            double[][] arr1 = new double[2][2];
            arr1[0][0] = scan.nextDouble();
            arr1[0][1] = scan.nextDouble();
            arr1[1][0] = scan.nextDouble();
            arr1[1][1] = scan.nextDouble();
            arr_list.add(arr1);
        }
        for (int i = 0; i < arr_list.size(); i++) {
            double[][] arr_reverse =new double[2][2];
            arr_reverse[0][0] = 1.0;
            arr_reverse[1][1] = 1.0;
            arr_reverse[0][1] = 0.0;
            arr_reverse[1][0] = 0.0;
            double[][] arr_now = arr_list.get(i);

            double beishu1 = arr_now[1][0]/arr_now[0][0];
            arr_now[1][0] -= arr_now[0][0] * beishu1;
            arr_now[1][1] -= arr_now[0][1] * beishu1;
            arr_reverse[1][0] -= arr_reverse[0][0] * beishu1;
            arr_reverse[1][1] -= arr_reverse[0][1] * beishu1;

            arr_reverse[1][1] /= arr_now[1][1];
            arr_reverse[1][0] /= arr_now[1][1];
            arr_now[1][1] = 1;

            double beishu2 = arr_now[0][1]/arr_now[1][1];
            arr_now[0][0] -= arr_now[1][0] * beishu2;
            arr_now[0][1] -= arr_now[1][1] * beishu2;
            arr_reverse[0][0] -= arr_reverse[1][0] * beishu2;
            arr_reverse[0][1] -= arr_reverse[1][1] * beishu2;

            arr_reverse[0][0] /= arr_now[0][0];
            arr_reverse[0][1] /= arr_now[0][0];
            arr_now[0][0] = 1;

            reverse_list.add(arr_reverse);
        }
        for (int i = 0; i < a; i++) {
            double[][] arrr = reverse_list.get(i);
            System.out.printf("%.2f ",arrr[0][0]);
            System.out.printf("%.2f\n",arrr[0][1]);
            System.out.printf("%.2f ",arrr[1][0]);
            if(i!=a-1){
                System.out.printf("%.2f\n",arrr[1][1]);
            }else{
                System.out.printf("%.2f",arrr[1][1]);
            }
        }
    }
}
